import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _class;

import React from 'react';
import { Button, Row } from 'antd'; // import queryString from 'query-string';

import { Bind } from 'lodash-decorators';
import intl from "../../utils/intl";
import { getEnvConfig } from "../../utils/iocUtils";
import { removeAccessToken, removeAllCookie, getSession, setSession } from "../../utils/utils";
import Icons from "../../components/Icons";
var Kickoff = (_dec = Bind(), (_class = /*#__PURE__*/function (_React$Component) {
  _inherits(Kickoff, _React$Component);

  var _super = _createSuper(Kickoff);

  function Kickoff() {
    _classCallCheck(this, Kickoff);

    return _super.apply(this, arguments);
  }

  _createClass(Kickoff, [{
    key: "handleReLogin",
    value: function handleReLogin() {
      var _getEnvConfig = getEnvConfig(),
          LOGIN_URL = _getEnvConfig.LOGIN_URL;

      var cacheLocation = getSession('redirectUrl');
      setSession('isErrorFlag', false);
      removeAccessToken();
      removeAllCookie(); // 由于 LOGIN_URL 可以 配置, 所以 做一次判断

      if (LOGIN_URL.includes('?')) {
        window.location.href = "".concat(LOGIN_URL, "&redirect_uri=").concat(cacheLocation); // 401 需要在登录后返回401的页面
      } else {
        window.location.href = "".concat(LOGIN_URL, "?redirect_uri=").concat(cacheLocation); // 401 需要在登录后返回401的页面
      }
    }
  }, {
    key: "render",
    value: function render() {
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Row, {
        type: "flex",
        justify: "center",
        style: {
          marginTop: 100
        }
      }, /*#__PURE__*/React.createElement(Icons, {
        type: "world-map",
        size: "250",
        color: "#003266",
        style: {
          width: 400,
          margin: 'auto',
          marginTop: -40
        }
      })), /*#__PURE__*/React.createElement(Row, {
        type: "flex",
        justify: "center"
      }, /*#__PURE__*/React.createElement("h1", {
        style: {
          marginTop: -40
        }
      }, intl.get('cpaas.common.view.message.title.unauthorized.reLogin').d('抱歉，您的账号已在其他地点登录，请点击下方按钮重新登录！'))), /*#__PURE__*/React.createElement(Row, {
        type: "flex",
        justify: "center"
      }, /*#__PURE__*/React.createElement(Button, {
        onClick: this.handleReLogin,
        size: "large",
        style: {
          backgroundColor: '#003266',
          width: 200,
          color: 'white',
          marginTop: 10
        }
      }, intl.get('cpaas.common.button.reLogin').d('重新登录'))));
    }
  }]);

  return Kickoff;
}(React.Component), (_applyDecoratedDescriptor(_class.prototype, "handleReLogin", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "handleReLogin"), _class.prototype)), _class));
export { Kickoff as default };